Skip to content

Add BLE transfer stall detection to prevent indefinite sync hangs#5

Open
deepseven wants to merge 1 commit intoskorokithakis:masterfrom
deepseven:pr/ble-stall-detection
Open

Add BLE transfer stall detection to prevent indefinite sync hangs#5
deepseven wants to merge 1 commit intoskorokithakis:masterfrom
deepseven:pr/ble-stall-detection

Conversation

@deepseven
Copy link
Copy Markdown

Replace the blind transferComplete.await() with a polling-based stall detector that checks buffer growth every 3 seconds. If data stops arriving for 6 consecutive seconds (2 polls), the transfer is considered stalled and automatically retried.

This catches a real-world failure mode where the BLE connection stays alive but the firmware stops sending notifications (e.g. Android drops some packets silently). The previous approach would wait the full timeout (45s) before retrying, while this detects the problem in 6 seconds.

Also splits the broad catch(Exception) into specific handlers for TimeoutCancellationException, IOException, and CancellationException for clearer error logging.

Replace the blind transferComplete.await() with a polling-based stall detector that checks buffer growth every 3 seconds. If data stops arriving for 6 consecutive seconds (2 polls), the transfer is considered stalled and automatically retried.

This catches a real-world failure mode where the BLE connection stays alive but the firmware stops sending notifications (e.g. Android drops some packets silently). The previous approach would wait the full timeout (45s) before retrying, while this detects the problem in 6 seconds.

Also splits the broad catch(Exception) into specific handlers for TimeoutCancellationException, IOException, and CancellationException for clearer error logging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant